﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AdvancedCollections
{
    public class SkipListNode<T>
    {
        private static readonly Random _randomHeightGenerator = new Random();
        private LinkedListNode<T>[] _nodes;

        public SkipListNode(T value)
        {
            _nodes = new LinkedListNode<T>[GetSkipListHeight()];

            for (int i = 0; i < _nodes.Length; i++)
            {
                _nodes[i] = new LinkedListNode<T>(value);
            }
        }

        public T Value { get; private set; }

        private static int GetSkipListHeight()
        {
            int height = 1;

            while ((_randomHeightGenerator.Next() % 2) == 1)
                height++;

            return height;
        }
    }
}